/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bash.jcouture.util.swing;


import com.bash.compta.data.Depense;

import java.util.List;
import java.util.Locale;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author bashizip
 */
public class SousTotalTableModel extends AbstractTableModel {

    private List<Depense> data;
    private String[] colones = {"", "", "", "",
    "", "", "", ""};

       double totalEfectifs = 0,
                totalUSD = 0,
                totalFC = 0;

    public SousTotalTableModel(List<Depense> data) {
        this.data = data;


        for (Depense d : data) {
            totalEfectifs += d.getCompte().getEffectif();

        }

        for (Depense d : data) {
            totalUSD += d.getMontant();

        }
        for (Depense d : data) {
            totalFC += d.getMontantCDF();

        }
    }

    public SousTotalTableModel() {
    }

    public int getRowCount() {
        return 1;
    }

    public int getColumnCount() {
        return colones.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {

        Object toReturn = null;

        switch (columnIndex) {
            case 0:
                toReturn = "";
                break;
            case 1:
                toReturn = "";
                break;
            case 2:

                toReturn = " SOUS TOTAL";
                break;
            case 3:
                toReturn = totalEfectifs;
                break;
            case 4:
                toReturn = MyStringUtils.toCurrencyFormat(totalUSD, Locale.US);
                break;
            case 5:
                toReturn = MyStringUtils.toCustomCurrencyFormat(totalFC);
                break;
            case 6:
                toReturn = "";
                break;
            case 7:
                toReturn = "";
                break;

        }
        return toReturn;

    }

    @Override
    public String getColumnName(int column) {
        return colones[column];
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }
}
